function output = expdiscountMLE(params)

d = params(1);
p = params(2); % precision
% p = 1;
% alpha = params(2); % 1 = risk neutral
alpha = 1;

global input predicted

N = size(input,1);
predicted = zeros(N,1);
tookll = input(:,size(input,2));

loglikely = 0;
for i = 1:N
    ull = (input(i,4)^alpha)*d^(input(i,3)/12);
    uss = (input(i,2)^alpha)*d^(input(i,1)/12);
    diff = uss-ull;
    predicted(i) = 1/(1+exp(p*diff)); % likelihood of choosing LL
    
   if predicted(i)==0
        predicted(i)=.00000001;
    elseif predicted(i)==1
        predicted(i)=.99999999;
   end
   % likelyLL if LL, (1-likelyLL) if SS
   likelihood = tookll(i)*log(predicted(i))+(1-tookll(i))*log(1-predicted(i));
   loglikely = loglikely + likelihood;
end

output = -loglikely;

return;